package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/** 区域类型枚举 */
public enum AreaTypeEnum {
    COUNTRY(1, "国家"),
    PROVINCE(2, "省份"),
    CITY(3, "城市"),
    COUNTY(4, "地区"), // 县、镇、区等
    ;

    /**
     * 特征值
     */
    @JsonValue
    @Getter
    private Integer value;
    /**
     * 描述
     */
    @Getter
    private String description;

    AreaTypeEnum(int value, String description) {
        this.value = value;
        this.description = description;
    }

    private static final Map<Integer, AreaTypeEnum> VALUES = new HashMap<>();

    static {
        for (final AreaTypeEnum areaTypeEnum : AreaTypeEnum.values()) {
            AreaTypeEnum.VALUES.put(areaTypeEnum.getValue(), areaTypeEnum);
        }
    }

    @JsonCreator
    public static AreaTypeEnum getByValue(Integer value) {
        return AreaTypeEnum.VALUES.get(value);
    }

    public int value() {
        return this.value;
    }
    public String description() {
        return this.description;
    }
}
